package com.jic.manager.impl;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.manager.mapper.RegionProvinceMapper;
import com.jic.manager.entity.RegionProvince;
import com.jic.manager.service.RegionProvinceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 地址销售区域关联表
 * @author : 
 * @email : 
 * @since : 2020-02-08 05:59:30
 * @version : v1.0.0
 */
@Service
public class RegionProvinceServiceImpl implements RegionProvinceService {

    @Autowired
    private RegionProvinceMapper regionProvinceMapper;

    @Override
    public long insert(RegionProvince regionProvince) {
        long flag = regionProvinceMapper.insert(regionProvince);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return regionProvinceMapper.delete(id);
    }

    @Override
    public long update(RegionProvince regionProvince) {
        return regionProvinceMapper.update(regionProvince);
    }

    @Override
    public RegionProvince queryByPrimaryKey(Long id){
        return regionProvinceMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<RegionProvince> query(RegionProvince regionProvince){
        return regionProvinceMapper.query(regionProvince);
    }

    @Override
    public PageResult<RegionProvince> queryPage(RegionProvince regionProvince, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<RegionProvince> list = regionProvinceMapper.queryPage(startIndex, pageQuery.getLimit(), regionProvince);
        long count = regionProvinceMapper.queryPageCount(regionProvince);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}